<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../css/aui.css">
    <link rel="stylesheet" type="text/css" href="../../css/aui-slide.css">
    <link rel="stylesheet" type="text/css" href="../../css/api.css">
    <script type="text/javascript" src="../../script/api.js"></script>
    <script type="text/javascript" src="../../script/jquery.min1.js"></script>
    <script type="text/javascript" src="../../script/Popt.js"></script>
<script type="text/javascript" src="../../script/cityjson.js"></script>
<script type="text/javascript" src="../../script/citySet.js"></script>
<script type="text/javascript" src="../../script/area.js"></script>

</head>
<style type="text/css">
    * { -ms-word-wrap: break-word; word-wrap: break-word; }
    html { -webkit-text-size-adjust: none; text-size-adjust: none; }

    .wrap{width:464px;height:34px;margin:2rem auto;border:0;position:relative;}
    .input{position:absolute;top:0;left:0;width:457px;margin:0;padding-left:5px;height:30px;line-height:30px;font-size:12px;border:1px solid #c9cacb;}
    s{position:absolute;top:1px;right:0;width:32px;height:32px;background:url("img/arrow.png") no-repeat;}
    ._citys { width: 450px; display: inline-block; border:0rem solid #eee; padding: 5px; position: relative; right:5rem;top:3.3rem;}

    ._citys span { color: #05920a; height: 15px; width: 15px; line-height: 15px; text-align: center; border-radius: 3px; position: absolute; right: -4rem; top: 3rem; border: 1px solid #05920a; cursor: pointer; }
    ._citys0 { width: 12rem; height: 34px; line-height: 34px; display: inline-block; border-bottom: 2px solid #05920a; padding: 0px 5px; font-size:14px; font-weight:bold; margin-left:14rem; }
    ._citys0 li { display: inline-block; line-height: 34px; font-size: 15px; color: #888; width: 80px; text-align: center; cursor: pointer; }
    ._citys1 { display: inline-block; padding: 10px 0;    width: 12rem;float: right; margin-right:-5rem;}
    ._citys1 a { width: 83px; height: 35px; display: inline-block; background-color: #f5f5f5; color: #666; margin-left: 6px; margin-top: 3px; line-height: 35px; text-align: center; cursor: pointer; font-size: 12px; border-radius: 5px; overflow: hidden; }
    ._citys1 a:hover { color: #fff; background-color: #05920a; }
    .AreaS { background-color: #05920a !important; color: #fff !important; }
    </style>
<body><script src="/demos/googlegg.js"></script>
    <header class="aui-bar aui-bar-nav" style="top:-0.1rem; background-color: #f7911b;height:3rem;">
      <inpiut value="aaa" id="city">
        <a href="" class="aui-pull-left"><span class="aui-iconfont aui-icon-left" onclick="api.closeWin()"></span></a>
        <div class="aui-title">个人信息</div>
    </header>
   
    <div class="aui-content" id="personalinfo">

    </div>
</body>
<script type="text/javascript">
    $("body").on('click','#city',function(e){SelCity(this,e);})
    
    </script>
<script type="text/javascript">
    apiready = function() {
        var user_id = $api.byId('user_id');
        var user_name = $api.byId('user_name');
        var user_sex = $api.byId('user_sex');
        var user_address = $api.byId('user_address');
        var user_age = $api.byId('user_age');
        var user_sign = $api.byId('sign');
        




        personallyAJAX('', '');

        function personallyAJAX(name, sex, address,age,sign) {
            var token = {
                token: $api.getStorage('token'),
                name: name,
                sex: sex,
                address: address,
                age: age,
                sign: sign
            };
            api.ajax({
                url: 'http://www.mk517.com/webApi/personalInfo.php',
                method: 'post',
                "headers": {
                    "Content-Type": "application/json"
                },
                dataType: 'json',
                data: {
                    body: token
                }
            }, function(ret, err) {
                
                if (ret) {
                    Name = ret.user_name;
                    sex = ret.user_sex;
                    address = ret.address;
                    age = ret.age;
                    sign = ret.sign;


                    if(ret.user_sex==0){
                        sex='男';
                    }else if(ret.user_sex==1){
                        sex='女';
                    }else if(ret.user_sex==2){
                        sex='保密';
                    }else{
                        sex=' ';
                    }
                  
                    $api.byId('personalinfo').innerHTML = '<ul class="aui-list aui-media-list">' +
                        '<li class="aui-list-item aui-list-item-middle">' +
                        '<div class="aui-media-list-item-inner">' +
                        '<div class="aui-list-item-inner">' +
                        '<div class="aui-list-item-title"><span>用户头像</span></div></div>' +
                        '<div class="aui-list-item-right" style="width: 3rem;margin-right:1.2rem;">' +
                        '<img id="user_avater" src="' + (ret.id ? '' : ret.user_avaterUrl) + '" class="aui-img-round" style="margin-top:0.2rem;"/>' +
                        '</div></div></li>' +
                        '<li class="aui-list-item aui-list-item-middle">' +
                        '<div class="aui-media-list-item-inner">' +
                        '<div class="aui-list-item-inner">' +
                        '<div class="aui-list-item-title"  onclick="changeName();"><span>昵称</span><span class="aui-pull-right"  id="user_name" style="margin-right:1rem;float;right;"> ' + (ret.id ? '' : Name) + '<span class="aui-iconfont aui-icon-right" style="padding-left:0.6rem;float:right;margin-right:-1rem;"></span></span ></div></div></div></li>' +
                        '<li class="aui-list-item aui-list-item-middle">' +
                        '<div class="aui-media-list-item-inner">' +
                        '<div class="aui-list-item-inner">' +
                        '<div class="aui-list-item-title"><span>用户ID</span><span class="aui-pull-right" id="user_id" style="margin-right:0.8rem;">' + (ret.id ? '' : ret.user_id) + '</span> </div></div></div></li>' +
                        
                        '<li class="aui-list-item aui-list-item-middle">' +
                        '<div class="aui-media-list-item-inner">' +
                        '<div class="aui-list-item-inner">' +
                        '<div class="aui-list-item-title"><span>性别</span><select class="aui-pull-right" id="user_sex" style="margin:0rem -13.5rem;"  onblur="fun()" ><option value ="2" >保密</option><option value ="0">男</option><option value ="1">女</option></span> </select><span class="aui-iconfont aui-icon-right" style="float:right;margin-righ:0rem;"></span></div></div></div></li>' +
                        

                        '<li class="aui-list-item aui-list-item-middle">' +
                        '<div class="aui-media-list-item-inner">' +
                        '<div class="aui-list-item-inner">' +
                        '<div class="aui-list-item-title" onclick="changeage();"><span>年龄</span><span class="aui-pull-right" id="user_age" style="margin-right:1rem;">' + (ret.id ? '' : age) + '岁<span class="aui-iconfont aui-icon-right" style="float:right;padding-left:0.7rem;margin-right:-1rem;"></span></span> </div></div></div></li>' +
                        

                        '<li class="aui-list-item aui-list-item-middle">' +
                        '<div class="aui-media-list-item-inner">' +
                        '<div class="aui-list-item-inner">' +
                        '<div class="aui-list-item-title" onclick="changeadd();">地区<div class="aui-pull-right" id="user_address" style="float:right;margin-right:1rem;"><input  onblur="fun1()" style="backgroung-color:red;float:right;margin:-0.1rem 2rem ;rem;  text-align: right;width:13rem;" class="input" name="" id="city" type="text" value="' + (ret.id ? '' : address) + '"  autocomplete="off" readonly="true"><span class="aui-iconfont aui-icon-right" style="float:right;margin-right:-1rem;"></span></div> </div></div></div></li>' +
                        

                        '<li class="aui-list-item aui-list-item-middle">' +
                        '<div class="aui-media-list-item-inner">' +
                        '<div class="aui-list-item-inner">' +
                        '<div class="aui-list-item-title" onclick="changesign();"><span>个性签名</span><span class="aui-pull-right" id="user_sign" style="margin-right:1rem;"><span style="display:block;line-height:1rem;width:15rem;">' + (ret.id ? '' : sign) + '</span><span class="aui-iconfont aui-icon-right" style="padding-left:1rem;float:right;margin-right:-1rem;"></span></span></div></div></div></li></ul>'
                       
                    


                } else {
                    // alert(JSON.stringify(err));
                }
            });
        }

window.fun=function(){
    var sex=$api.byId('user_sex').value;
    
        personallyAJAX('',sex, '','','');
        api.sendEvent({
                            name: 'updateSex',
                            extra: {
                                sex: sex
                            }

                        });
}

window.fun1=function(){
    var address=$api.byId('city').value;
    alert(address);
        personallyAJAX('','', address,'','');
      
}
        window.changeage = function() {
            api.prompt({
                title: '修改年龄',
                buttons: ['确定', '取消']
            }, function(ret, err) {
                if (ret) {
                    if (ret.buttonIndex == 1) {
                        age = ret.text;
                        var re = /^[1-9]+[0-9]*]*$/;
                        if (!re.test(age)) {
                    　　　
                    alert("请输入数字!");
                    　　}else{
                        　age=ret.text;
                        personallyAJAX('','','',age, '');
                        api.sendEvent({
                            name: 'updateAge',
                            extra: {
                                age: ret.text
                            }

                        });
                    }
                    //     isNaN(numValue)
                    // parseInt(ret);
                    }
                } else {
                    // alert(JSON.stringify(err));
                }
                window.location.reload();
            });
        }
       

        window.changeName = function() {
            api.prompt({
                title: '修改昵称',
                buttons: ['确定', '取消']
            }, function(ret, err) {
                if (ret) {
                    if (ret.buttonIndex == 1) {
                        name = ret.text;
                        personallyAJAX(name, '');
                        api.sendEvent({
                            name: 'updateName',
                            extra: {
                                name: ret.text
                            }

                        });
                    }
                } else {
                    // alert(JSON.stringify(err));
                }
                window.location.reload();
            });
          
        }

        window.changesign = function() {
            api.prompt({
                title: '修改签名',
                buttons: ['确定', '取消']
            }, function(ret, err) {
                if (ret) {
                    if (ret.buttonIndex == 1) {
                        sign = ret.text;
                        personallyAJAX('','','','',sign);
                        api.sendEvent({
                            name: 'updateSign',
                            extra: {
                                sign: ret.text
                            }
                        });
                    }
                } else {
                    // alert(JSON.stringify(err));
                }
                window.location.reload();
            });

        }

    }
</script>

</html>
